const store = {
    state:{
        number:20
    },
    // 同步
    actions:{
        add1(newState:{number:number},action:{type:string}){
            newState.number++
        },
        add2(newState:{number:number},action:{type:string,value:number}){
            newState.number+=action.value;
        }
    },
    // 异步
    asyncActions:{
        asyncAdd1(dispatch:Function){
            setTimeout(()=>{
                dispatch({type:"add1"})
            },1000)
        },
        asyncAdd2(dispatch:Function){
            setTimeout(()=>{
                dispatch({type:"add2",value:2})
            },1000)
        }
    },
    // 名字统一管理
    actionNames:{}
}
let actionNames = {}
for(let key in store.actions){
    actionNames[key] = key
}
store.actionNames = actionNames

export default store